package com.kun.controller;

import com.kun.context.LoginMemberContext;
import com.kun.req.PassengerQueryReq;
import com.kun.req.PassengerSaveReq;
import com.kun.resp.CommonResp;
import com.kun.resp.PageResp;
import com.kun.resp.PassengerQueryResp;
import com.kun.service.PassengerService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: MemberController
 * @Description: ...
 * @author: kunkun
 * @date: 2025/7/8 15:27
 */
@RestController
@RequestMapping("/passenger")
public class PassengerController {

    @Autowired
    private PassengerService passengerService;


    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody PassengerSaveReq passengerSaveReq){
        passengerSaveReq.setMemberId(LoginMemberContext.getId());
        passengerService.save(passengerSaveReq);
        return new CommonResp<Object>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<PassengerQueryResp>> queryList(@Valid PassengerQueryReq passengerQueryReq){
        passengerQueryReq.setMemberId(LoginMemberContext.getId());
        PageResp<PassengerQueryResp> resp = passengerService.queryList(passengerQueryReq);
        return new CommonResp<>(resp);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable("id") Long id){
        passengerService.delete(id);
        return new CommonResp<Object>();
    }


}
